package org.example.fanruan;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @author Yyming
 * @version 10.0
 * Created by Yyming on 2020/9/7
 */
public class T17 {
    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        in.nextToken();
        int n = (int) in.nval;
        int[] ints = new int[n];
        for (int i = 0; i < n; i++) {
            in.nextToken();
            ints[i] = (int) in.nval;
        }
        int max = 0;
        int temp = 0;
        int end = 0;
        for (int i = 0; i < ints.length; i++) {
            temp += ints[i];
            if (temp > max) {
                end = i;
                max = temp;
            }
        }
        temp = max;
        for (int i = 0; i < end + 1; i++) {
            temp = temp - ints[i];
            if (temp > max) {
                max = temp;
            }
        }
        System.out.println((double) max);
    }
}
